<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户注册</title>
<style type="text/css">
	label{
		color:red;
	}
</style>
<script type="text/javascript">
	function checkUser(name){
		//Get  Post   URL
		//第一步：创建XMLHttpRequest对象，此对象由js默认提供，直接使用即可
		var httpRequest = null;
		if (window.XMLHttpRequest) {//分浏览器创建XMLHttp对象  
			httpRequest = new XMLHttpRequest();  
     	} else if (window.ActiveXObject) {  
    	 	httpRequest = new ActiveXObject("Microsoft.XMLHTTP")  
     	}  
		
		//定义回调函数
		httpRequest.onreadystatechange = function stateChanged() {
			if (httpRequest.readyState == 4) {
				if (httpRequest.status == 200) {
					document.getElementById("msg").innerHTML=httpRequest.responseText;
				}else{
					alert("HTTP error" + httpRequest.status);
				}
			}
		}
		
		//第二步：制定向服务器端发送请求的资源
		httpRequest.open("GET","UserCheckServlet?username=" + name,true);
		//第三步：发送请求
		httpRequest.send(null);
	}
</script>
</head>
<body>
	<form action="RegisterServlet" method="post">
		用户名：<input type="text" name="username" onblur="checkUser(this.value)"><label id="msg"></label><br/>
		密码：<input type="password" name="password"><br/>
		邮箱：<input type="text" name="email"/><br/>
		生日：<input type="text" name="birthday"/><br/>
		<input type="submit" value="注册">
	</form>
</body>
</html>